package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysCrmKhExtend;
import com.ruoyi.system.service.ISysCrmKhExtendService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户附加信息Controller
 * 
 * @author SYF
 * @date 2025-05-09
 */
@RestController
@RequestMapping("/system/crmkhextend")
public class SysCrmKhExtendController extends BaseController {

    @Autowired
    private ISysCrmKhExtendService sysCrmKhExtendService;

    /**
     * 查询客户附加信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SysCrmKhExtend sysCrmKhExtend) {
        startPage();
        List<SysCrmKhExtend> list = sysCrmKhExtendService.selectSysCrmKhExtendList(sysCrmKhExtend);
        return getDataTable(list);
    }

    /**
     * 导出客户附加信息列表
     */
    @Log(title = "客户附加信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysCrmKhExtend sysCrmKhExtend) {
        List<SysCrmKhExtend> list = sysCrmKhExtendService.selectSysCrmKhExtendList(sysCrmKhExtend);
        ExcelUtil<SysCrmKhExtend> util = new ExcelUtil<SysCrmKhExtend>(SysCrmKhExtend.class);
        util.exportExcel(response, list, "客户附加信息数据");
    }

    /**
     * 获取客户附加信息详细信息
     */
    @GetMapping(value = "/{khId}")
    public AjaxResult getInfo(@PathVariable("khId") String khId) {
        return success(sysCrmKhExtendService.selectSysCrmKhExtendByKhId(khId));
    }

    /**
     * 新增客户附加信息
     */
    @Log(title = "客户附加信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysCrmKhExtend sysCrmKhExtend) {
        return toAjax(sysCrmKhExtendService.insertSysCrmKhExtend(sysCrmKhExtend));
    }

    /**
     * 修改客户附加信息
     */
    @Log(title = "客户附加信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysCrmKhExtend sysCrmKhExtend) {
        return toAjax(sysCrmKhExtendService.updateSysCrmKhExtend(sysCrmKhExtend));
    }

    /**
     * 删除客户附加信息
     */
    @Log(title = "客户附加信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{khIds}")
    public AjaxResult remove(@PathVariable String[] khIds) {
        return toAjax(sysCrmKhExtendService.deleteSysCrmKhExtendByKhIds(khIds));
    }
}
